using IcsSEMCtrl.Event;
using IcsSEMCtrl.Service.EventBroker;
using IcsSEMCtrl.Service.Logger;
using IcsSEMCtrl.Util.Client;
using Lifter.Device;
using Lifter.Device.Unit;
using Lifter.Event.Lifter;
using Lifter.Global;
using Lifter.Global.Device;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using TKT.Lifter.CIM.Lifter.Event.Lifter;
using static TKT.Lifter.CIM.Lifter.Global.SysTemConstant;

namespace Lifter.Gui.Monitor.Popups
{
    public class PortInfomationDetail : UIForm
    {
        private delegate void delegateUpdateWidgetEvent();
        private static Dictionary<string, PortInfomationDetail> PortInfoDetailbyName = new Dictionary<string, PortInfomationDetail>();
        private WrapperRemoteEvent wre = new WrapperRemoteEvent();
        private LifterSEM LftSem = (LifterSEM)Naming.GetDeviceManager().GetDevice();
        private string portId = "";
        private IContainer components = null;
        private Panel panel1;
        private Label label5;
        private Label label6;
        private Label label2;
        private Label label1;
        private Panel panel2;
        private Label label13;
        private Label label11;
        private Label label10;
        private UISmoothLabel lblPortID;
        private UITextBox txtOutPutEnable;
        private UITextBox txtCapacity;
        private Label label12;
        private Label label14;
        private UIComboBox cmbOfflineAutoCmdDestPort;
        private Label label15;
        private Label label16;
        private Label PortPriority;
        private UITextBox txtPortPriority;
        private UISwitch btnCVWatinTimeOut;
        private UISwitch btnOFFlineAutoCmd;
        private UISwitch btnUseDestPort;
        private UISwitch btnPortUse;
        private Label lbIsPortStatus;
        private Label lbPortStatus;
        private GroupBox panelBack;
        public static Dictionary<string, PortInfomationDetail> PortInformationDetailbyName = new Dictionary<string, PortInfomationDetail>();
        private LifterPortDirectionEvent.enumLifterPortDirectionEventType portDirEvent;
        private delegate void delegatePortStatusEnable();
        private UIComboBox txtPortDir;
        private UIComboBox txtHandOffType;
        private UISwitch btnBCREnableMode;
        private Label label3;
        private Label lbBCR;
        private LifterPort hostDevice = null;
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;
                cp.ExStyle |= 0x02000000; // 用双缓冲绘制窗口的所有子控件
                return cp;
            }
        }
        public void Subscribe()
        {
            if (this.hostDevice != null)
            {
                if (!PortInfomationDetail.PortInformationDetailbyName.ContainsKey(this.hostDevice.ElementId))
                {
                    PortInfomationDetail.PortInformationDetailbyName.Add(this.hostDevice.ElementId, this);
                }
            }
        }
        public string PortId
        {
            get
            {
                return this.portId;
            }
            set
            {
                this.portId = value;
                this.PortInformInit(value);
            }
        }
        public PortInfomationDetail()
        {
            this.InitializeComponent();
            try
            {
                this.hostDevice = this.LftSem.GetLifterPort(this.portId);
                Subscribe();
            }
            catch (NullReferenceException)
            {
            }
        }
        public void UpdateDelegateEvent()
        {
            base.BeginInvoke(new PortInfomationDetail.delegateUpdateWidgetEvent(this.UpdatePortInfoDetail));
        }
        /// <summary>
        /// 更新port详细页面信息
        /// </summary>
		private void UpdatePortInfoDetail()
        {
            try
            {
                if (this.LftSem == null)
                {
                    this.LftSem = (LifterSEM)Naming.GetDeviceManager().GetDevice();
                }
                this.hostDevice = this.LftSem.GetLifterPort(this.portId);
                Subscribe();
            }
            catch (NullReferenceException)
            {
            }

            LifterPort lifterPort = this.LftSem.GetLifterPort(this.portId);

            this.lblPortID.Text = lifterPort.HostID;
            this.txtHandOffType.Text = HandOffType.ValueToString(lifterPort.PortHandoffType);
            this.txtCapacity.Text = lifterPort.PortSize.ToString();
            this.txtPortDir.Text = lifterPort.PortInOutMode.ToString();
            this.txtOutPutEnable.Text = lifterPort.IsOutputEnable.ToString();

            this.btnCVWatinTimeOut.Active = lifterPort.IsUSECVWaitTimeOut;
            this.btnOFFlineAutoCmd.Active = lifterPort.IsUSEOfflineAutoCMD;
            this.btnUseDestPort.Active = lifterPort.UseDestPortFlag;
            this.btnBCREnableMode.Active = lifterPort.BCREnableMode == enumBCREnableMode.ENABLE;
            if (this.btnPortUse.Active != lifterPort.UseChange)
            {
                this.btnPortUse.Active = lifterPort.UseChange;
            }
            this.cmbOfflineAutoCmdDestPort.Items.Clear();
            if (lifterPort.UseChange)
            {
                this.btnCVWatinTimeOut.Enabled = true;
                this.btnOFFlineAutoCmd.Enabled = true;
                this.btnUseDestPort.Enabled = true;
                this.btnBCREnableMode.Enabled = true;
                this.txtHandOffType.Enabled = true;
                if (lifterPort.IsPortDirChangeEnable)
                {
                    this.txtPortDir.Enabled = true;
                }
                else
                {
                    this.txtPortDir.Enabled = false;
                }
                this.cmbOfflineAutoCmdDestPort.Enabled = true;
                if (lifterPort.PortInOutMode == enumLifterPortDirection.IN)
                {
                    foreach (LifterPort current2 in this.LftSem.GetLifterPortAll().Values)
                    {
                        if (current2.PortInOutMode == enumLifterPortDirection.OUT)
                        {
                            this.cmbOfflineAutoCmdDestPort.Items.Add(current2.HostID);
                        }
                    }
                }
            }
            else
            {
                this.btnCVWatinTimeOut.Enabled = false;
                this.btnOFFlineAutoCmd.Enabled = false;
                this.btnUseDestPort.Enabled = false;
                this.btnBCREnableMode.Enabled = false;
                this.txtHandOffType.Enabled = false;
                this.txtPortDir.Enabled = false;
                this.cmbOfflineAutoCmdDestPort.Enabled = false;
            }

            if (!string.IsNullOrEmpty(lifterPort.OfflineAutoCMD_DestPort))
            {
                this.cmbOfflineAutoCmdDestPort.Text = lifterPort.OfflineAutoCMD_DestPort;
            }
            else
            {
                this.cmbOfflineAutoCmdDestPort.Text = lifterPort.GetUserDefinedPropertyValue("OFF_LINE_DEST_PORT", "", false);
            }
        }
        public void PortInformInit(string elementId)
        {
            this.AddSubscription(LifterPortEvent.FormSubject(elementId));
            this.AddSubscription(LifterPortDirectionEvent.FormSubject(elementId));
            this.UpdatePortInfoDetail();
        }
        private void buttonOK_Click(object sender, EventArgs e)
        {
            this.RemoveSubscription(LifterPortEvent.FormSubject(this.portId));
            this.RemoveSubscription(LifterPortDirectionEvent.FormSubject(this.portId));
            base.Hide();
        }
        public void AddSubscription(string subject)
        {
            EventBrokerManager eventBrokerManager = Naming.GetEventBrokerManager();
            RemoteEvent remoteEventForSubscribe = eventBrokerManager.GetRemoteEventForSubscribe(subject);
            if (remoteEventForSubscribe != null)
            {
                try
                {
                    remoteEventForSubscribe.RemoteEventReceived += new RemoteEventHandler(this.wre.WrapperRemoteEventReceivedHandler);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message.ToString());
                }
                this.wre.WrapperRemoteEventReceived += new RemoteEventHandler(this.ReceiveECPEvent);
            }
        }
        public void RemoveSubscription(string subject)
        {
            EventBrokerManager eventBrokerManager = Naming.GetEventBrokerManager();
            RemoteEvent remoteEventForUnsubscribe = eventBrokerManager.GetRemoteEventForUnsubscribe(subject);
            if (remoteEventForUnsubscribe != null)
            {
                try
                {
                    remoteEventForUnsubscribe.RemoteEventReceived -= new RemoteEventHandler(this.wre.WrapperRemoteEventReceivedHandler);
                    this.wre.WrapperRemoteEventReceived -= new RemoteEventHandler(this.ReceiveECPEvent);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message.ToString());
                }
            }
        }
        public void ReceiveECPEvent(ECPEvent ecpEvent)
        {
            if (ecpEvent is LifterPortEvent)
            {
                LifterPortEvent lifterPortEvent = (LifterPortEvent)ecpEvent;
                if (base.Visible)
                {
                    if (this.portId == lifterPortEvent.LifterPortId)
                    {
                        this.UpdateDelegateEvent();
                    }
                }
                else
                {
                    this.portId = lifterPortEvent.LifterPortId;
                    this.UpdateDelegateEvent();
                }
            }
            if (ecpEvent is LifterPortDirectionEvent)
            {
                LifterPortDirectionEvent lifterPortDirectionEvent = (LifterPortDirectionEvent)ecpEvent;
                if (base.Visible)
                {
                    if (this.portId == lifterPortDirectionEvent.LifterPortId)
                    {
                        this.UpdateDelegateEvent();
                    }
                }
                else
                {
                    this.portId = lifterPortDirectionEvent.LifterPortId;
                    this.UpdateDelegateEvent();
                }
            }
        }
        public void OnEventTerminate()
        {
            if (this.portId != "")
            {
                this.RemoveSubscription(LifterPortEvent.FormSubject(this.portId));
                this.RemoveSubscription(LifterPortDirectionEvent.FormSubject(this.portId));
            }
        }
        
        private void cmbOfflineAutoCmdDestPort_SelectedIndexChanged(object sender, EventArgs e)
        {
            LifterPort lifterPort = this.LftSem.GetLifterPort(this.portId);
            if (!string.IsNullOrEmpty(this.cmbOfflineAutoCmdDestPort.Text))
            {
                lifterPort.OfflineAutoCMD_DestPort = this.cmbOfflineAutoCmdDestPort.Text;
                lifterPort.SetUserDefinedPropertyValue("OFF_LINE_DEST_PORT", this.cmbOfflineAutoCmdDestPort.Text, lifterPort.HostID);
            }
        }
        private void cmbOfflineAutoCmdDestPort_TextChanged(object sender, EventArgs e)
        {
            LifterPort lifterPort = this.LftSem.GetLifterPort(this.portId);
            if (!string.IsNullOrEmpty(this.cmbOfflineAutoCmdDestPort.Text))
            {
                lifterPort.OfflineAutoCMD_DestPort = this.cmbOfflineAutoCmdDestPort.Text;
                lifterPort.SetUserDefinedPropertyValue("OFF_LINE_DEST_PORT", this.cmbOfflineAutoCmdDestPort.Text, lifterPort.HostID);
            }
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing && this.components != null)
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }
        private void InitializeComponent()
        {
            this.panel1 = new System.Windows.Forms.Panel();
            this.btnBCREnableMode = new Sunny.UI.UISwitch();
            this.label3 = new System.Windows.Forms.Label();
            this.lbBCR = new System.Windows.Forms.Label();
            this.txtHandOffType = new Sunny.UI.UIComboBox();
            this.txtPortDir = new Sunny.UI.UIComboBox();
            this.btnPortUse = new Sunny.UI.UISwitch();
            this.lbIsPortStatus = new System.Windows.Forms.Label();
            this.lbPortStatus = new System.Windows.Forms.Label();
            this.btnUseDestPort = new Sunny.UI.UISwitch();
            this.btnOFFlineAutoCmd = new Sunny.UI.UISwitch();
            this.btnCVWatinTimeOut = new Sunny.UI.UISwitch();
            this.txtPortPriority = new Sunny.UI.UITextBox();
            this.PortPriority = new System.Windows.Forms.Label();
            this.label15 = new System.Windows.Forms.Label();
            this.label16 = new System.Windows.Forms.Label();
            this.cmbOfflineAutoCmdDestPort = new Sunny.UI.UIComboBox();
            this.label14 = new System.Windows.Forms.Label();
            this.label12 = new System.Windows.Forms.Label();
            this.txtOutPutEnable = new Sunny.UI.UITextBox();
            this.txtCapacity = new Sunny.UI.UITextBox();
            this.label13 = new System.Windows.Forms.Label();
            this.label11 = new System.Windows.Forms.Label();
            this.label10 = new System.Windows.Forms.Label();
            this.label5 = new System.Windows.Forms.Label();
            this.label6 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.panel2 = new System.Windows.Forms.Panel();
            this.lblPortID = new Sunny.UI.UISmoothLabel();
            this.panelBack = new System.Windows.Forms.GroupBox();
            this.panel1.SuspendLayout();
            this.panel2.SuspendLayout();
            this.panelBack.SuspendLayout();
            this.SuspendLayout();
            // 
            // panel1
            // 
            this.panel1.BackColor = System.Drawing.Color.AliceBlue;
            this.panel1.Controls.Add(this.btnBCREnableMode);
            this.panel1.Controls.Add(this.label3);
            this.panel1.Controls.Add(this.lbBCR);
            this.panel1.Controls.Add(this.txtHandOffType);
            this.panel1.Controls.Add(this.txtPortDir);
            this.panel1.Controls.Add(this.btnPortUse);
            this.panel1.Controls.Add(this.lbIsPortStatus);
            this.panel1.Controls.Add(this.lbPortStatus);
            this.panel1.Controls.Add(this.btnUseDestPort);
            this.panel1.Controls.Add(this.btnOFFlineAutoCmd);
            this.panel1.Controls.Add(this.btnCVWatinTimeOut);
            this.panel1.Controls.Add(this.txtPortPriority);
            this.panel1.Controls.Add(this.PortPriority);
            this.panel1.Controls.Add(this.label15);
            this.panel1.Controls.Add(this.label16);
            this.panel1.Controls.Add(this.cmbOfflineAutoCmdDestPort);
            this.panel1.Controls.Add(this.label14);
            this.panel1.Controls.Add(this.label12);
            this.panel1.Controls.Add(this.txtOutPutEnable);
            this.panel1.Controls.Add(this.txtCapacity);
            this.panel1.Controls.Add(this.label13);
            this.panel1.Controls.Add(this.label11);
            this.panel1.Controls.Add(this.label10);
            this.panel1.Controls.Add(this.label5);
            this.panel1.Controls.Add(this.label6);
            this.panel1.Controls.Add(this.label2);
            this.panel1.Controls.Add(this.label1);
            this.panel1.Controls.Add(this.panel2);
            this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.panel1.Location = new System.Drawing.Point(10, 21);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(592, 426);
            this.panel1.TabIndex = 0;
            // 
            // btnBCREnableMode
            // 
            this.btnBCREnableMode.ActiveText = "On";
            this.btnBCREnableMode.Font = new System.Drawing.Font("微软雅黑", 12F);
            this.btnBCREnableMode.InActiveText = "Off";
            this.btnBCREnableMode.Location = new System.Drawing.Point(500, 384);
            this.btnBCREnableMode.MinimumSize = new System.Drawing.Size(1, 1);
            this.btnBCREnableMode.Name = "btnBCREnableMode";
            this.btnBCREnableMode.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None;
            this.btnBCREnableMode.Size = new System.Drawing.Size(75, 29);
            this.btnBCREnableMode.Style = Sunny.UI.UIStyle.Custom;
            this.btnBCREnableMode.TabIndex = 123;
            this.btnBCREnableMode.Text = "uiSwitch2";
            this.btnBCREnableMode.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            this.btnBCREnableMode.MouseClick += new System.Windows.Forms.MouseEventHandler(this.btnBCREnableMode_MouseClick);
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label3.Location = new System.Drawing.Point(331, 394);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(136, 15);
            this.label3.TabIndex = 122;
            this.label3.Text = "(On:enable Off:disable)";
            this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lbBCR
            // 
            this.lbBCR.AutoSize = true;
            this.lbBCR.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lbBCR.Location = new System.Drawing.Point(331, 366);
            this.lbBCR.Name = "lbBCR";
            this.lbBCR.Size = new System.Drawing.Size(139, 22);
            this.lbBCR.TabIndex = 121;
            this.lbBCR.Text = "BCR禁用启用模式";
            this.lbBCR.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // txtHandOffType
            // 
            this.txtHandOffType.DataSource = null;
            this.txtHandOffType.DropDownStyle = Sunny.UI.UIDropDownStyle.DropDownList;
            this.txtHandOffType.DropDownWidth = 300;
            this.txtHandOffType.FillColor = System.Drawing.Color.White;
            this.txtHandOffType.FillColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(251)))), ((int)(((byte)(250)))));
            this.txtHandOffType.FilterMaxCount = 50;
            this.txtHandOffType.Font = new System.Drawing.Font("微软雅黑", 12F);
            this.txtHandOffType.ItemHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(242)))), ((int)(((byte)(238)))));
            this.txtHandOffType.Items.AddRange(new object[] {
            "AGV",
            "MGV",
            "RGV"});
            this.txtHandOffType.ItemSelectBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(190)))), ((int)(((byte)(172)))));
            this.txtHandOffType.ItemSelectForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(251)))), ((int)(((byte)(250)))));
            this.txtHandOffType.Location = new System.Drawing.Point(130, 86);
            this.txtHandOffType.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
            this.txtHandOffType.MinimumSize = new System.Drawing.Size(63, 0);
            this.txtHandOffType.Name = "txtHandOffType";
            this.txtHandOffType.Padding = new System.Windows.Forms.Padding(0, 0, 30, 2);
            this.txtHandOffType.Size = new System.Drawing.Size(160, 29);
            this.txtHandOffType.Style = Sunny.UI.UIStyle.Custom;
            this.txtHandOffType.TabIndex = 120;
            this.txtHandOffType.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
            this.txtHandOffType.Watermark = "";
            this.txtHandOffType.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            this.txtHandOffType.SelectedIndexChanged += new System.EventHandler(this.txtHandOffType_SelectedIndexChanged);
            // 
            // txtPortDir
            // 
            this.txtPortDir.DataSource = null;
            this.txtPortDir.DropDownStyle = Sunny.UI.UIDropDownStyle.DropDownList;
            this.txtPortDir.DropDownWidth = 300;
            this.txtPortDir.FillColor = System.Drawing.Color.White;
            this.txtPortDir.FillColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(251)))), ((int)(((byte)(250)))));
            this.txtPortDir.FilterMaxCount = 50;
            this.txtPortDir.Font = new System.Drawing.Font("微软雅黑", 12F);
            this.txtPortDir.ItemHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(242)))), ((int)(((byte)(238)))));
            this.txtPortDir.Items.AddRange(new object[] {
            "IN",
            "OUT",
            "BOTH"});
            this.txtPortDir.ItemSelectBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(190)))), ((int)(((byte)(172)))));
            this.txtPortDir.ItemSelectForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(251)))), ((int)(((byte)(250)))));
            this.txtPortDir.Location = new System.Drawing.Point(130, 236);
            this.txtPortDir.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
            this.txtPortDir.MinimumSize = new System.Drawing.Size(63, 0);
            this.txtPortDir.Name = "txtPortDir";
            this.txtPortDir.Padding = new System.Windows.Forms.Padding(0, 0, 30, 2);
            this.txtPortDir.Size = new System.Drawing.Size(160, 29);
            this.txtPortDir.Style = Sunny.UI.UIStyle.Custom;
            this.txtPortDir.TabIndex = 107;
            this.txtPortDir.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
            this.txtPortDir.Watermark = "";
            this.txtPortDir.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            this.txtPortDir.SelectedIndexChanged += new System.EventHandler(this.txtPortDir_SelectedIndexChanged);
            // 
            // btnPortUse
            // 
            this.btnPortUse.Active = true;
            this.btnPortUse.ActiveText = "On";
            this.btnPortUse.Font = new System.Drawing.Font("微软雅黑", 12F);
            this.btnPortUse.InActiveText = "Off";
            this.btnPortUse.Location = new System.Drawing.Point(500, 88);
            this.btnPortUse.MinimumSize = new System.Drawing.Size(1, 1);
            this.btnPortUse.Name = "btnPortUse";
            this.btnPortUse.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None;
            this.btnPortUse.Size = new System.Drawing.Size(75, 29);
            this.btnPortUse.Style = Sunny.UI.UIStyle.Custom;
            this.btnPortUse.TabIndex = 119;
            this.btnPortUse.Text = "uiSwitch2";
            this.btnPortUse.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            this.btnPortUse.ValueChanged += new Sunny.UI.UISwitch.OnValueChanged(this.btnPortUse_ValueChanged);
            // 
            // lbIsPortStatus
            // 
            this.lbIsPortStatus.AutoSize = true;
            this.lbIsPortStatus.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lbIsPortStatus.Location = new System.Drawing.Point(331, 105);
            this.lbIsPortStatus.Name = "lbIsPortStatus";
            this.lbIsPortStatus.Size = new System.Drawing.Size(133, 15);
            this.lbIsPortStatus.TabIndex = 118;
            this.lbIsPortStatus.Text = "(On:enable Off:unable)";
            this.lbIsPortStatus.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lbPortStatus
            // 
            this.lbPortStatus.AutoSize = true;
            this.lbPortStatus.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lbPortStatus.Location = new System.Drawing.Point(331, 77);
            this.lbPortStatus.Name = "lbPortStatus";
            this.lbPortStatus.Size = new System.Drawing.Size(142, 22);
            this.lbPortStatus.TabIndex = 117;
            this.lbPortStatus.Text = "Port禁用启用模式";
            this.lbPortStatus.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // btnUseDestPort
            // 
            this.btnUseDestPort.ActiveText = "On";
            this.btnUseDestPort.Font = new System.Drawing.Font("微软雅黑", 12F);
            this.btnUseDestPort.InActiveText = "Off";
            this.btnUseDestPort.Location = new System.Drawing.Point(500, 312);
            this.btnUseDestPort.MinimumSize = new System.Drawing.Size(1, 1);
            this.btnUseDestPort.Name = "btnUseDestPort";
            this.btnUseDestPort.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None;
            this.btnUseDestPort.Size = new System.Drawing.Size(75, 29);
            this.btnUseDestPort.Style = Sunny.UI.UIStyle.Custom;
            this.btnUseDestPort.TabIndex = 116;
            this.btnUseDestPort.Text = "uiSwitch2";
            this.btnUseDestPort.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            this.btnUseDestPort.ValueChanged += new Sunny.UI.UISwitch.OnValueChanged(this.btnUseDestPort_ValueChanged);
            // 
            // btnOFFlineAutoCmd
            // 
            this.btnOFFlineAutoCmd.ActiveText = "On";
            this.btnOFFlineAutoCmd.Font = new System.Drawing.Font("微软雅黑", 12F);
            this.btnOFFlineAutoCmd.InActiveText = "Off";
            this.btnOFFlineAutoCmd.Location = new System.Drawing.Point(500, 236);
            this.btnOFFlineAutoCmd.MinimumSize = new System.Drawing.Size(1, 1);
            this.btnOFFlineAutoCmd.Name = "btnOFFlineAutoCmd";
            this.btnOFFlineAutoCmd.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None;
            this.btnOFFlineAutoCmd.Size = new System.Drawing.Size(75, 29);
            this.btnOFFlineAutoCmd.Style = Sunny.UI.UIStyle.Custom;
            this.btnOFFlineAutoCmd.TabIndex = 115;
            this.btnOFFlineAutoCmd.Text = "uiSwitch2";
            this.btnOFFlineAutoCmd.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            this.btnOFFlineAutoCmd.ActiveChanged += new System.EventHandler(this.btnOFFlineAutoCmd_ActiveChanged);
            // 
            // btnCVWatinTimeOut
            // 
            this.btnCVWatinTimeOut.ActiveText = "On";
            this.btnCVWatinTimeOut.Font = new System.Drawing.Font("微软雅黑", 12F);
            this.btnCVWatinTimeOut.InActiveText = "Off";
            this.btnCVWatinTimeOut.Location = new System.Drawing.Point(500, 161);
            this.btnCVWatinTimeOut.MinimumSize = new System.Drawing.Size(1, 1);
            this.btnCVWatinTimeOut.Name = "btnCVWatinTimeOut";
            this.btnCVWatinTimeOut.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None;
            this.btnCVWatinTimeOut.Size = new System.Drawing.Size(75, 29);
            this.btnCVWatinTimeOut.Style = Sunny.UI.UIStyle.Custom;
            this.btnCVWatinTimeOut.TabIndex = 114;
            this.btnCVWatinTimeOut.Text = "uiSwitch2";
            this.btnCVWatinTimeOut.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            this.btnCVWatinTimeOut.ValueChanged += new Sunny.UI.UISwitch.OnValueChanged(this.btnCVWatinTimeOut_ValueChanged);
            // 
            // txtPortPriority
            // 
            this.txtPortPriority.ButtonWidth = 100;
            this.txtPortPriority.CanEmpty = true;
            this.txtPortPriority.Cursor = System.Windows.Forms.Cursors.IBeam;
            this.txtPortPriority.Enabled = false;
            this.txtPortPriority.Font = new System.Drawing.Font("微软雅黑", 12F);
            this.txtPortPriority.Location = new System.Drawing.Point(130, 439);
            this.txtPortPriority.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
            this.txtPortPriority.Maximum = 9D;
            this.txtPortPriority.MaxLength = 2;
            this.txtPortPriority.Minimum = 0D;
            this.txtPortPriority.MinimumSize = new System.Drawing.Size(1, 1);
            this.txtPortPriority.Name = "txtPortPriority";
            this.txtPortPriority.Padding = new System.Windows.Forms.Padding(5);
            this.txtPortPriority.ShowText = false;
            this.txtPortPriority.Size = new System.Drawing.Size(160, 29);
            this.txtPortPriority.Style = Sunny.UI.UIStyle.Custom;
            this.txtPortPriority.TabIndex = 113;
            this.txtPortPriority.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
            this.txtPortPriority.Type = Sunny.UI.UITextBox.UIEditType.Integer;
            this.txtPortPriority.Visible = false;
            this.txtPortPriority.Watermark = "";
            this.txtPortPriority.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            this.txtPortPriority.TextChanged += new System.EventHandler(this.txtPortPriority_TextChanged);
            // 
            // PortPriority
            // 
            this.PortPriority.Enabled = false;
            this.PortPriority.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.PortPriority.Location = new System.Drawing.Point(45, 441);
            this.PortPriority.Name = "PortPriority";
            this.PortPriority.Size = new System.Drawing.Size(67, 23);
            this.PortPriority.TabIndex = 110;
            this.PortPriority.Text = "优先级";
            this.PortPriority.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.PortPriority.Visible = false;
            // 
            // label15
            // 
            this.label15.AutoSize = true;
            this.label15.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label15.Location = new System.Drawing.Point(331, 328);
            this.label15.Name = "label15";
            this.label15.Size = new System.Drawing.Size(117, 15);
            this.label15.TabIndex = 109;
            this.label15.Text = "(On:use Off:notuse)";
            this.label15.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label16
            // 
            this.label16.AutoSize = true;
            this.label16.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label16.Location = new System.Drawing.Point(331, 300);
            this.label16.Name = "label16";
            this.label16.Size = new System.Drawing.Size(154, 22);
            this.label16.TabIndex = 107;
            this.label16.Text = "使用目的地(Online)";
            this.label16.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // cmbOfflineAutoCmdDestPort
            // 
            this.cmbOfflineAutoCmdDestPort.DataSource = null;
            this.cmbOfflineAutoCmdDestPort.DropDownStyle = Sunny.UI.UIDropDownStyle.DropDownList;
            this.cmbOfflineAutoCmdDestPort.DropDownWidth = 300;
            this.cmbOfflineAutoCmdDestPort.FillColor = System.Drawing.Color.White;
            this.cmbOfflineAutoCmdDestPort.FillColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(251)))), ((int)(((byte)(250)))));
            this.cmbOfflineAutoCmdDestPort.FilterMaxCount = 50;
            this.cmbOfflineAutoCmdDestPort.Font = new System.Drawing.Font("微软雅黑", 12F);
            this.cmbOfflineAutoCmdDestPort.ItemHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(242)))), ((int)(((byte)(238)))));
            this.cmbOfflineAutoCmdDestPort.ItemSelectBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(190)))), ((int)(((byte)(172)))));
            this.cmbOfflineAutoCmdDestPort.ItemSelectForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(251)))), ((int)(((byte)(250)))));
            this.cmbOfflineAutoCmdDestPort.Location = new System.Drawing.Point(130, 379);
            this.cmbOfflineAutoCmdDestPort.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
            this.cmbOfflineAutoCmdDestPort.MinimumSize = new System.Drawing.Size(63, 0);
            this.cmbOfflineAutoCmdDestPort.Name = "cmbOfflineAutoCmdDestPort";
            this.cmbOfflineAutoCmdDestPort.Padding = new System.Windows.Forms.Padding(0, 0, 30, 2);
            this.cmbOfflineAutoCmdDestPort.Size = new System.Drawing.Size(160, 29);
            this.cmbOfflineAutoCmdDestPort.Style = Sunny.UI.UIStyle.Custom;
            this.cmbOfflineAutoCmdDestPort.TabIndex = 106;
            this.cmbOfflineAutoCmdDestPort.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
            this.cmbOfflineAutoCmdDestPort.Watermark = "";
            this.cmbOfflineAutoCmdDestPort.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            this.cmbOfflineAutoCmdDestPort.TextChanged += new System.EventHandler(this.cmbOfflineAutoCmdDestPort_TextChanged);
            this.cmbOfflineAutoCmdDestPort.SelectedIndexChanged += new System.EventHandler(this.cmbOfflineAutoCmdDestPort_SelectedIndexChanged);
            // 
            // label14
            // 
            this.label14.AutoSize = true;
            this.label14.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label14.Location = new System.Drawing.Point(331, 255);
            this.label14.Name = "label14";
            this.label14.Size = new System.Drawing.Size(117, 15);
            this.label14.TabIndex = 105;
            this.label14.Text = "(On:use Off:notuse)";
            this.label14.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label12
            // 
            this.label12.AutoSize = true;
            this.label12.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label12.Location = new System.Drawing.Point(331, 185);
            this.label12.Name = "label12";
            this.label12.Size = new System.Drawing.Size(117, 15);
            this.label12.TabIndex = 104;
            this.label12.Text = "(On:use Off:notuse)";
            this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // txtOutPutEnable
            // 
            this.txtOutPutEnable.Cursor = System.Windows.Forms.Cursors.IBeam;
            this.txtOutPutEnable.Enabled = false;
            this.txtOutPutEnable.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.txtOutPutEnable.Location = new System.Drawing.Point(130, 312);
            this.txtOutPutEnable.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
            this.txtOutPutEnable.MinimumSize = new System.Drawing.Size(1, 16);
            this.txtOutPutEnable.Name = "txtOutPutEnable";
            this.txtOutPutEnable.ShowButton = true;
            this.txtOutPutEnable.ShowText = false;
            this.txtOutPutEnable.Size = new System.Drawing.Size(160, 29);
            this.txtOutPutEnable.Style = Sunny.UI.UIStyle.Custom;
            this.txtOutPutEnable.TabIndex = 102;
            this.txtOutPutEnable.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
            this.txtOutPutEnable.Watermark = "";
            this.txtOutPutEnable.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            // 
            // txtCapacity
            // 
            this.txtCapacity.Cursor = System.Windows.Forms.Cursors.IBeam;
            this.txtCapacity.Enabled = false;
            this.txtCapacity.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.txtCapacity.Location = new System.Drawing.Point(130, 164);
            this.txtCapacity.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
            this.txtCapacity.MinimumSize = new System.Drawing.Size(1, 16);
            this.txtCapacity.Name = "txtCapacity";
            this.txtCapacity.ShowButton = true;
            this.txtCapacity.ShowText = false;
            this.txtCapacity.Size = new System.Drawing.Size(160, 29);
            this.txtCapacity.Style = Sunny.UI.UIStyle.Custom;
            this.txtCapacity.TabIndex = 100;
            this.txtCapacity.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
            this.txtCapacity.Watermark = "";
            this.txtCapacity.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            // 
            // label13
            // 
            this.label13.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label13.Location = new System.Drawing.Point(50, 381);
            this.label13.Name = "label13";
            this.label13.Size = new System.Drawing.Size(62, 23);
            this.label13.TabIndex = 95;
            this.label13.Text = "目的地";
            this.label13.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label11
            // 
            this.label11.AutoSize = true;
            this.label11.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label11.Location = new System.Drawing.Point(331, 227);
            this.label11.Name = "label11";
            this.label11.Size = new System.Drawing.Size(172, 22);
            this.label11.TabIndex = 88;
            this.label11.Text = "自动生成指令(Offline)";
            this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label10
            // 
            this.label10.AutoSize = true;
            this.label10.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label10.Location = new System.Drawing.Point(331, 157);
            this.label10.Name = "label10";
            this.label10.Size = new System.Drawing.Size(138, 22);
            this.label10.TabIndex = 86;
            this.label10.Text = "超时自动生成指令";
            this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label5
            // 
            this.label5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label5.Location = new System.Drawing.Point(34, 315);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(78, 23);
            this.label5.TabIndex = 74;
            this.label5.Text = "能否出料";
            this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // label6
            // 
            this.label6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label6.Location = new System.Drawing.Point(17, 166);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(95, 23);
            this.label6.TabIndex = 72;
            this.label6.Text = "buffer数量";
            this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label2
            // 
            this.label2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label2.Location = new System.Drawing.Point(18, 239);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(94, 23);
            this.label2.TabIndex = 68;
            this.label2.Text = "InOut模式";
            this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label1
            // 
            this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label1.Location = new System.Drawing.Point(12, 88);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(100, 23);
            this.label1.TabIndex = 66;
            this.label1.Text = "Port类型";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // panel2
            // 
            this.panel2.Controls.Add(this.lblPortID);
            this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
            this.panel2.Location = new System.Drawing.Point(0, 0);
            this.panel2.Name = "panel2";
            this.panel2.Size = new System.Drawing.Size(592, 60);
            this.panel2.TabIndex = 65;
            // 
            // lblPortID
            // 
            this.lblPortID.Font = new System.Drawing.Font("微软雅黑", 30F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblPortID.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
            this.lblPortID.Location = new System.Drawing.Point(3, 0);
            this.lblPortID.Name = "lblPortID";
            this.lblPortID.Size = new System.Drawing.Size(586, 60);
            this.lblPortID.Style = Sunny.UI.UIStyle.Custom;
            this.lblPortID.TabIndex = 87;
            this.lblPortID.Text = "SunnyUI";
            this.lblPortID.TextAlign = System.Drawing.ContentAlignment.TopCenter;
            this.lblPortID.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            // 
            // panelBack
            // 
            this.panelBack.BackColor = System.Drawing.Color.Transparent;
            this.panelBack.Controls.Add(this.panel1);
            this.panelBack.Dock = System.Windows.Forms.DockStyle.Fill;
            this.panelBack.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.panelBack.Location = new System.Drawing.Point(0, 35);
            this.panelBack.Name = "panelBack";
            this.panelBack.Padding = new System.Windows.Forms.Padding(10, 7, 9, 7);
            this.panelBack.Size = new System.Drawing.Size(611, 454);
            this.panelBack.TabIndex = 1;
            this.panelBack.TabStop = false;
            // 
            // PortInfomationDetail
            // 
            this.BackColor = System.Drawing.Color.AliceBlue;
            this.ClientSize = new System.Drawing.Size(611, 489);
            this.Controls.Add(this.panelBack);
            this.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "PortInfomationDetail";
            this.Style = Sunny.UI.UIStyle.Custom;
            this.Text = "Port详细设置";
            this.ZoomScaleRect = new System.Drawing.Rectangle(15, 15, 615, 545);
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.PortInfomationDetail_FormClosing);
            this.panel1.ResumeLayout(false);
            this.panel1.PerformLayout();
            this.panel2.ResumeLayout(false);
            this.panelBack.ResumeLayout(false);
            this.ResumeLayout(false);

        }

        private void PortInfomationDetail_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.buttonOK_Click(sender, e);
            e.Cancel = true;
        }
        /// <summary>
        /// add by syr
        /// 增加Port优先级
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="value"></param>
        private void txtPortPriority_TextChanged(object sender, EventArgs e)
        {
            string priority = txtPortPriority.Text;
            LifterPort lifterPort = this.LftSem.GetLifterPort(this.portId);
            lifterPort.PortPriority = priority;
            lifterPort.SetUserDefinedPropertyValue("PORT_PRIORITY", priority, lifterPort.HostID);
        }
        /// <summary>
        /// add by syr
        /// 更改控件类型，由输入框改为按钮形式
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="value"></param>
        private void btnCVWatinTimeOut_ValueChanged(object sender, bool value)
        {
            LifterPort lifterPort = this.LftSem.GetLifterPort(this.portId);
            if (this.btnCVWatinTimeOut.Active.ToString() == "True")
            {
                lifterPort.IsUSECVWaitTimeOut = true;
                lifterPort.SetUserDefinedPropertyValue("USE_CV_WAIT_IN_TIME_OUT", "T", lifterPort.HostID);
            }
            else
            {
                lifterPort.IsUSECVWaitTimeOut = false;
                lifterPort.SetUserDefinedPropertyValue("USE_CV_WAIT_IN_TIME_OUT", "F", lifterPort.HostID);
            }
        }
        /// <summary>
        /// add by syr
        /// 更改控件类型，由输入框改为按钮形式
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="value"></param>
        private void btnUseDestPort_ValueChanged(object sender, bool value)
        {
            LifterPort lifterPort = this.LftSem.GetLifterPort(this.portId);
            if (this.btnUseDestPort.Active.ToString() == "True")
            {
                lifterPort.UseDestPortFlag = true;
                lifterPort.SetUserDefinedPropertyValue("USE_DEST_PORT_FLAG", "T", lifterPort.HostID);
            }
            else
            {
                lifterPort.UseDestPortFlag = false;
                lifterPort.SetUserDefinedPropertyValue("USE_DEST_PORT_FLAG", "F", lifterPort.HostID);
            }
        }
        private void btnPortUse_ValueChanged(object sender, bool value)
        {
            LifterPort lifterPort = this.LftSem.GetLifterPort(this.portId);
            if (this.btnPortUse.Active)
            {
                lifterPort.O_ENABLEMODECHANGE = true;
                lifterPort.UseChange = true;
            }
            else
            {
                lifterPort.O_ENABLEMODECHANGE = false;
                lifterPort.UseChange = false;
            }
            LogHelper.operationLogger(string.Format("用户[{0}]进行了Port[{1}],禁用启用模式切换操作", this.LftSem.UserName, lifterPort.HostID));
            LftSem.InsertUserOperation(LftSem.UserName, string.Format("用户[{0}]进行了Port[{1}],禁用启用模式切换操作", this.LftSem.UserName, lifterPort.HostID));
        }
        private void txtPortDir_SelectedIndexChanged(object sender, EventArgs e)
        {
            LifterPort lifterPort = this.LftSem.GetLifterPort(this.portId);
            try
            {
                enumLifterPortDirection enumLifterPort = (enumLifterPortDirection)Enum.Parse(typeof(enumLifterPortDirection), this.txtPortDir.Text);
                lifterPort.PortModeReq(enumLifterPort);
                LogHelper.operationLogger(string.Format("用户[{0}]进行了Port[{1}],[{2}]模式切换操作", this.LftSem.UserName, lifterPort.HostID, this.txtPortDir.Text));
                LftSem.InsertUserOperation(LftSem.UserName, string.Format("用户[{0}]进行了Port[{1}],[{2}]模式切换操作", this.LftSem.UserName, lifterPort.HostID, this.txtPortDir.Text));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        private void txtHandOffType_SelectedIndexChanged(object sender, EventArgs e)
        {
            LifterPort lifterPort = this.LftSem.GetLifterPort(this.portId);
            try
            {
                HandOffType handOffType;
                if (this.txtHandOffType.Text == "MGV")
                {
                    handOffType = HandOffType.MGV;
                }
                else if (this.txtHandOffType.Text == "AGV")
                {
                    handOffType = HandOffType.AGV;
                }
                else
                {
                    handOffType = HandOffType.RGV;
                }
                lifterPort.PortOperationModeCode(handOffType);
                LogHelper.operationLogger(string.Format("用户[{0}]进行了Port[{1}],[{2}]模式切换操作", this.LftSem.UserName, lifterPort.HostID,handOffType));
                LftSem.InsertUserOperation(LftSem.UserName, string.Format("用户[{0}]进行了Port[{1}],[{2}]模式切换操作", this.LftSem.UserName, lifterPort.HostID, handOffType));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// BCR禁用使用模式切换
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBCREnableMode_MouseClick(object sender, MouseEventArgs e)
        {
            LifterPort lifterPort = this.LftSem.GetLifterPort(this.portId);
            lifterPort.BCREnableModeMethod(this.btnBCREnableMode.Active);
            LogHelper.operationLogger(string.Format("用户[{0}]进行了Port[{1}],BCR禁用启用操作", this.LftSem.UserName, lifterPort.HostID));
            LftSem.InsertUserOperation(LftSem.UserName, string.Format("用户[{0}]进行了Port[{1}],BCR禁用启用操作", this.LftSem.UserName, lifterPort.HostID));
        }

        private void btnOFFlineAutoCmd_ActiveChanged(object sender, EventArgs e)
        {
            LifterPort lifterPort = this.LftSem.GetLifterPort(this.portId);
            if (this.btnOFFlineAutoCmd.Active)
            {
                lifterPort.IsUSEOfflineAutoCMD = true;
                lifterPort.SetUserDefinedPropertyValue("USE_OFFLINE_AUTOCMD", "T", lifterPort.HostID);
            }
            else
            {
                lifterPort.IsUSEOfflineAutoCMD = false;
                lifterPort.SetUserDefinedPropertyValue("USE_OFFLINE_AUTOCMD", "F", lifterPort.HostID);
            }
        }
    }
}
